package com.huan.social.qq.connect;

import com.huan.social.qq.api.Qq;
import com.huan.social.qq.api.impl.QqTemplate;
import lombok.Getter;
import lombok.Setter;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;

/**
 * Qq 服务提供商
 *
 * @author huan.fu
 * @date 2018/9/25 - 12:01
 */
@Getter
@Setter
public class QqServiceProvider extends AbstractOAuth2ServiceProvider<Qq> {

	private String clientId;
	private String clientSecret;
	private String openIdUrl;
	private String userInfoUrl;

	public QqServiceProvider(String clientId, String clientSecret, String openIdUrl, String userInfoUrl, String authorizeUrl, String accessTokenUrl) {
		super(new QqOauthTemplate(clientId, clientSecret, authorizeUrl, accessTokenUrl));
		this.clientId = clientId;
		this.openIdUrl = openIdUrl;
		this.userInfoUrl = userInfoUrl;
	}

	@Override
	public Qq getApi(String accessToken) {
		return new QqTemplate(this.getClientId(), accessToken, this.getOpenIdUrl(), this.getUserInfoUrl());
	}
}
